<template>
  <div class="app-container">
    <div class="custom_card_0" v-show="showSearch">
      <el-form :model="queryParams" ref="queryForm" :inline="true">
        <el-form-item label="订单编号" prop="orderNo" label-width="80px">
          <el-input
            v-model="queryParams.orderNo"
            placeholder="请输入订单编号"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item
          label="购买人姓名"
          prop="purchaserName"
          label-width="100px"
        >
          <el-input
            v-model="queryParams.purchaserName"
            placeholder="请输入购买人姓名"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item
          label="购买人手机号"
          prop="purchaserPhone"
          label-width="100px"
        >
          <el-input
            v-model="queryParams.purchaserPhone"
            placeholder="请输入购买人手机号"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="成交时间" prop="tradingHours" label-width="100px">
          <el-date-picker
            clearable
            size="small"
            v-model="queryParams.tradingHours"
            type="date"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="选择成交时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="handleQuery"
            >搜索</el-button
          >
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
            >重置</el-button
          >
        </el-form-item>
      </el-form>
    </div>
    <!-- <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['order:mkOrder:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['order:mkOrder:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['order:mkOrder:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          :loading="exportLoading"
          @click="handleExport"
          v-hasPermi="['order:mkOrder:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row> -->
    <div class="custom_card">
      <el-table v-loading="loading" :data="mkOrderList" border>
        <el-table-column
          label="订单编号"
          min-width="160"
          align="center"
          prop="orderNo"
          :show-overflow-tooltip="true"
        />
        <!-- <el-table-column label="业务系统编号" min-width="160" align="center" prop="businessId" /> -->
        <el-table-column
          label="购买金额/元"
          min-width="140"
          align="center"
          prop="businessPrice"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="购买人"
          min-width="140"
          align="center"
          prop="purchaserName"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="购买人手机号"
          min-width="140"
          align="center"
          prop="purchaserPhone"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="一级分销伙伴昵称"
          min-width="160"
          align="center"
          prop="distributorsLevelOneNick"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="一级分销伙伴名称"
          min-width="160"
          align="center"
          prop="distributorsLevelOneName"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="一级分销伙伴手机号"
          min-width="160"
          align="center"
          prop="distributorsLevelOnePhone"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="一级分销金额/元"
          min-width="160"
          align="center"
          prop="primaryDistributionAmount"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="二级分销伙伴昵称"
          min-width="160"
          align="center"
          prop="distributorsLevelTwoNick"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="二级分销伙伴名称"
          min-width="160"
          align="center"
          prop="distributorsLevelTwoName"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="二级分销伙伴手机号"
          min-width="160"
          align="center"
          prop="distributorsLevelTwoPhone"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="二级分销金额/元"
          min-width="160"
          align="center"
          prop="secondaryDistributionAmount"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="成交时间"
          align="center"
          prop="tradingHours"
          min-width="160"
          :show-overflow-tooltip="true"
        ></el-table-column>
        <!-- <template slot-scope="scope">
          <span>{{ parseTime(scope.row.tradingHours, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column> -->
        <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="handDetail(scope.row)">详情</el-button>
        </template>
      </el-table-column> -->
      </el-table>

      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
  </div>
</template>

<script>
import { listMkOrder, exportMkOrder } from '@/api/marketing/mkOrder'

export default {
  name: 'MkOrder',
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 全名营销订单表格数据
      mkOrderList: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderNo: null,
        tradingHours: null,
        purchaserPhone: null,
        purchaserName: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    }
  },
  created() {
    this.getList()
  },
  methods: {
    /** 查询全名营销订单列表 */
    getList() {
      this.loading = true
      listMkOrder(this.queryParams).then((response) => {
        this.mkOrderList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.form = {
        orderNo: null,
        tradingHours: null,
      }
      this.resetForm('form')
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.handleQuery()
    },
    /** 详情按钮操作 */
    handDetail(row) {
      this.$router.push({ path: '/mkOrder/detail/' + row.id })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams
      this.$modal
        .confirm('是否确认导出所有全名营销订单数据项？')
        .then(() => {
          this.exportLoading = true
          return exportMkOrder(queryParams)
        })
        .then((response) => {
          this.$download.name(response.msg)
          this.exportLoading = false
        })
        .catch(() => {})
    },
  },
}
</script>
